Fix shadow bin argument passing causing findLast errors #912
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #911
The
socket-npmandsocket-npxcommands were failing with "rawBinArgs.findLast is not a function" errors. The root cause was incorrect argument passing in the shadow bin wrapper scripts.Problem
The shadow-bin/npm and shadow-bin/npx wrapper scripts were incorrectly passing the bin name as the first argument:
This caused the function parameters to shift:
argsparameter received the string'npm'or'npx'instead of an arrayargs.slice(0, terminatorPos), it returned a stringfindLast()method, causing the errorSolution
shadow-bin/npm: Removed the
'npm'argument since it's already hardcoded inshadowNpmBin()shadow-bin/npx:
shadowNpxBinfunction instead ofshadowNpmBin'npx'argument since it's already hardcoded inshadowNpxBin()Testing
Added comprehensive unit tests for both functions:
--) handlingfindLast()works correctlyfindLast()All 12 new tests pass.
Changes
Note
Fixes argument passing in
shadow-bin/npmandshadow-bin/npxand adds tests to validate array handling andfindLastbehavior.shadow-bin/npmto callshadowNpmBin(process.argv.slice(2), ...)(remove hardcoded bin arg).shadow-bin/npxto requiredist/shadow-npx-bin.jsand callshadowNpxBin(process.argv.slice(2), ...).src/shadow/npm/bin.test.mtsandsrc/shadow/npx/bin.test.mtscovering:--terminator handling.findLasterrors and correct progress flag resolution.Written by Cursor Bugbot for commit 99f023f. Configure here.